﻿using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace AlphaWindow
{
	internal static class SkinHelper
	{
		internal static GraphicsPath GetGraphicsPath(Control sender, bool _pLCorner, bool _pRCorner)
		{
			Rectangle baser = new Rectangle(sender.Left + 0, sender.Top + 0, sender.Width - 1, sender.Height - 1);

			GraphicsPath gg = new GraphicsPath();

			if (!_pLCorner && !_pRCorner)
			{
				gg.AddArc(new Rectangle(baser.Left, baser.Top, 8, 8), -180, 90);
				gg.AddLine(baser.Left + 4, baser.Top, baser.Right - 8, baser.Top);
				gg.AddArc(new Rectangle(baser.Right - 8, baser.Top, 8, 8), -90, 90);
				gg.AddLine(baser.Right, baser.Top + 4, baser.Right, baser.Bottom - 8);
				gg.AddArc(new Rectangle(baser.Right - 8, baser.Bottom - 8, 8, 8), 0, 90);
				gg.AddLine(baser.Right - 8, baser.Bottom, baser.Left + 4, baser.Bottom);
				gg.AddArc(new Rectangle(baser.Left, baser.Bottom - 8, 8, 8), 90, 90);
				gg.CloseFigure();
			}
			else if (_pLCorner && !_pRCorner)
			{
				gg.AddLine(baser.Left, baser.Top, baser.Right - 8, baser.Top);
				gg.AddArc(new Rectangle(baser.Right - 8, baser.Top, 8, 8), -90, 90);
				gg.AddLine(baser.Right, baser.Top + 4, baser.Right, baser.Bottom - 8);
				gg.AddArc(new Rectangle(baser.Right - 8, baser.Bottom - 8, 8, 8), 0, 90);
				gg.AddLine(baser.Right - 8, baser.Bottom, baser.Left, baser.Bottom);
				gg.CloseFigure();
			}
			else if (!_pLCorner && _pRCorner)
			{
				gg.AddArc(new Rectangle(baser.Left, baser.Top, 8, 8), -180, 90);
				gg.AddLine(baser.Left + 4, baser.Top, baser.Right, baser.Top);
				gg.AddLine(baser.Right, baser.Top, baser.Right, baser.Bottom);
				gg.AddLine(baser.Right, baser.Bottom, baser.Left + 4, baser.Bottom);
				gg.AddArc(new Rectangle(baser.Left, baser.Bottom - 8, 8, 8), 90, 90);
				gg.CloseFigure();
			}
			else if (_pLCorner && _pRCorner)
			{
				gg.AddLine(baser.Left, baser.Top, baser.Right, baser.Top);
				gg.AddLine(baser.Right, baser.Top, baser.Right, baser.Bottom);
				gg.AddLine(baser.Right, baser.Bottom, baser.Left, baser.Bottom);
				gg.CloseFigure();
			}
			return gg;
		}

	}
}
